import pickle
import numpy as np 
import os
import pickle
from tqdm import tqdm
from matplotlib import pyplot as plt 

# with open('log_NormTo1_rand0021TO0100_0221TO0300_labelGauss_Init4EN4_LossMSE-E200.txt', 'rb') as f:
with open('log_rand_labelGauss_DLR_LossMSE-E200.txt', 'rb') as f:
        # log_rand0001TO0200_HS2noise_E200_01
    history = pickle.load(f)

# print(history)

loss = history['loss']
val_loss = history['val_loss']
#acc = history['accuracy']
#val_acc = history['val_accuracy']
#val_loss = loss
#val_acc = acc

# make a figure
fig = plt.figure(figsize=(8,5))

plt.axes([0.2, 0.13, 0.7, 0.8])
plt.plot(loss[1:],label='train_loss')
plt.plot(val_loss[1:],label='val_loss')
font1 = {'family' : 'Times New Roman','weight' : 'normal','size' : 15,}
font2 = {'family' : 'Times New Roman','weight' : 'normal','size' : 18,}
plt.xlabel('Epochs', font2)
plt.ylabel('Loss', font2)
plt.tick_params(labelsize=15)
plt.title('Loss on Training and Validation Data', font2)
plt.legend(prop=font1)
#plt.xlim(0, 20)

# plt.axes([0.57, 0.13, 0.37, 0.8])
# plt.plot(acc,label='train_acc')
# plt.plot(val_acc,label='val_acc')
# font1 = {'family' : 'Times New Roman','weight' : 'normal','size' : 15,}
# font2 = {'family' : 'Times New Roman','weight' : 'normal','size' : 18,}
# plt.xlabel('Epochs', font2)
# plt.ylabel('Loss', font2)
# plt.tick_params(labelsize=15)
# plt.title('Loss on Training and Validation Data', font2)
# plt.legend(prop=font1)


# plt.subplots_adjust(hspace=0.1, wspace=0.4)
# # subplot loss
# ax1 = fig.add_subplot(121)
# ax1.plot(loss,label='train_loss')
# ax1.plot(val_loss,label='val_loss')
# #plt.xlim(0, 20)
# #plt.ylim(0.04,0.06)
# 
# font1 = {'family' : 'Times New Roman','weight' : 'normal','size' : 15,}
# font2 = {'family' : 'Times New Roman','weight' : 'normal','size' : 18,}
# 
# ax1.set_xlabel('Epochs', font2)
# ax1.set_ylabel('Loss', font2)
# plt.tick_params(labelsize=15)
# ax1.set_title('Loss on Training and Validation Data', font2)
# ax1.legend()
# # subplot acc
# ax2 = fig.add_subplot(122)
# ax2.plot(acc,label='train_acc')
# ax2.plot(val_acc,label='val_acc')
# ax2.set_xlabel('Epochs', font2)
# ax2.set_ylabel('Accuracy', font2)
# plt.tick_params(labelsize=15)
# ax2.set_title('Accuracy  on Training and Validation Data',font2)
# ax2.legend()
# # plt.tight_layout()
plt.show()


